package com.example.tencentdemo.service.Impl;

import com.example.tencentdemo.Mapper.chatAdminMapper;
import com.example.tencentdemo.entity.ChatAdmin;
import com.example.tencentdemo.service.ChatAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ChatAdminImpl implements ChatAdminService {
    @Autowired
    private chatAdminMapper chatAdminMapper;
    @Override
    public int insertChatAdmin(ChatAdmin chat_admin) {
        //判断表中是否有记录
        List<ChatAdmin> chatAdmins = chatAdminMapper.selectExitPeople(chat_admin.getAdmin_id(), chat_admin.getUser_id());

        if(chatAdmins.isEmpty()){
            chatAdminMapper.insertChatAdmin(chat_admin);
            return 1;
        }else{
            return 0;
        }

    }

    @Override
    public List<ChatAdmin> selectChatPeople(String admin_id) {
        List<ChatAdmin> chatAdmins = chatAdminMapper.selectChatPeople(admin_id);
        return chatAdmins;
    }
}
